<!DOCTYPE html>
<html lang="zh-CN">
    <head>
        <meta charset="utf-8">
        <meta http-equiv="X-UA-Compatible" content="IE=edge">
        <!-- 上述3个meta标签*必须*放在最前面，任何其他内容都*必须*跟随其后！ -->
        <meta name="viewport"
              content="width=device-width, initial-scale=1.0, maximum-scale=1.0, user-scalable=0,user-scalable=no,minimal-ui">
        <meta name="description" content="">
        <meta name="author" content="">
        <link rel="icon" href="../img/asset-favico.ico">
        <title>编辑信息</title>
        <link rel="stylesheet" href="../css/page-health-orderInfo.css"/>
        <link rel="stylesheet" href="../plugins/elementui/index.css"/>
        <script src="../plugins/jquery/dist/jquery.min.js"></script>
        <script src="../plugins/qrcode/qrcode.min.js"></script>
        <script src="../plugins/healthmobile.js"></script>
        <script src="../plugins/vue/vue.js"></script>
        <script src="../plugins/vue/axios-0.18.0.js"></script>
        <script src="../plugins/elementui/index.js"></script>
        <script>
            var id = getUrlParam("id");
            var price = getUrlParam("price");
        </script>

        <style>
            .form-info .info-form .brrow_ {
                border-bottom: 1px solid #ccc;
            }

            .brrow_ h3 {
                margin: 0px auto;
                text-align: center;
            }

            /*倒计时插件*/
            .validatePayBox {
                border-radius: 5px;
            }

            .validatePayBox .validatePayBox_bb {
                padding: 5px 15px;
                box-sizing: border-box;
            }

        </style>
    </head>
    <body data-spy="scroll" data-target="#myNavbar" data-offset="150">
        <div id="app" class="app">
            <!-- 页面头部 -->
            <div class="top-header">
                <span class="f-left"><i class="icon-back" onclick="history.go(-1)"></i></span>
                <span class="center">传智健康</span>
                <span class="f-right"><i class="icon-more"></i></span>
            </div>
            <!-- 页面内容 -->
            <div class="contentBox">
                <div class="form-info">
                    <form class="info-form">
                        <div class="date">
                            <h3 style="color: #e78126;text-align: center;font-weight:700;">需支付：{{orderPrice}}元</h3>
                        </div>

                        <div class="input-row brrow_" style="display: block">
                            <h3 style="margin: 0 auto;">微信扫码支付</h3>
                            <!--倒计时插件-->
                            <h3 style="margin: 0 auto;">
                                <span>支付剩余时间：</span>
                                <span style="font-size: 15px;" id="validatePayButton"></span>
                            </h3>
                        </div>

                        <div class="input-row single-radio" style="position: relative">
                            <!--二维码-->
                            <div style="margin: 0 auto;">
                                <div>
                                    <input id="text" type="text" value="http://vtfnyj.natappfree.cc/payNotify"
                                           style="width:80%" hidden/>
                                    <div id="qrcode" style="width:150px; height:150px;margin: 0 auto"></div>
                                </div>
                            </div>
                        </div>
                    </form>
                </div>
            </div>
        </div>

        </div>
        <script>
            var vue = new Vue({
                    el: '#app',
                    data: {
                        imgUrl: null,
                        setmeal: {},//套餐信息
                        orderInfo: {
                            orderType: "微信预约",
                            setmealId: id,
                            sex: '1'
                        },//预约信息
                        orderPrice: price
                    },
                    mounted() {
                        this.payValidate()
                    },
                    methods: {
                        //支付验证倒计时
                        payValidate() {
                            validatePayButton = $("#validatePayButton")[0];//使用变量validateCodeButton用来接收input标签
                            payclock = window.setInterval(doPayLoop, 1000); //每隔一秒执行一次doLoop方法
                        },
                        //提交预约
                        submitOrder() {
                            //校验身份证号格式
                            // if(!checkIdCard(this.orderInfo.idCard)){
                            //     this.$message.error('身份证号码输入错误，请重新输入');
                            //     return ;
                            // }
                            //发送请求提交预约数据  提交预约
                            axios.post("/order/add", this.orderInfo).then((res) => {
                                if (res.data.flag) {
                                    //res.data.data.id    = Result.data(Order)
                                    window.location.href = "orderSuccess.html?id=" + res.data.data.id
                                } else {
                                    this.$message.error(res.data.message);
                                }
                            })
                        }
                    }
                })
            ;
        </script>
        <script type="text/javascript">
            var qrcode = new QRCode(document.getElementById("qrcode"), {
                width: 100,
                height: 100
            });

            function makeCode() {
                var elText = document.getElementById("text");

                if (!elText.value) {
                    alert("Input a text");
                    elText.focus();
                    return;
                }

                qrcode.makeCode(elText.value);
            }

            makeCode();

            $("#text").on("blur", function () {
                makeCode();
            }).on("keydown", function (e) {
                if (e.keyCode == 13) {
                    makeCode();
                }
            });
        </script>
    </body>
</html>
